package main

import (
	"fmt"
)

type Rocket struct {
	World string
}

func (receiver *Rocket) Launch() {
	fmt.Println(receiver.World)
	fmt.Println("launching...")
}
func main() {
	//r := new(Rocket)
	//time.AfterFunc(2*time.Second, r.Launch)
	//time.Sleep(5 * time.Second)

}

type Path []Point

func (p Path) TranslateBy(offset Point) {
	var op func(p, q Point) Point
	op = Point.Add
	// 方法变量 原来的方法接受者为参数的第一个形参
	for i := range p {
		p[i] = op(p[i], offset)

	}
}

type Point struct {
	X, Y float64
}

func (p Point) Add(q Point) Point {
	return Point{p.X + q.X, p.Y + q.Y}
}
